package com.sc.nft.admin.controller;



import com.sc.nft.annotation.SysMemberLogin;
import com.sc.nft.dto.IdRequest;
import com.sc.nft.dto.TaskParticipationRecordDTO;
import com.sc.nft.dto.TaskRewardListDTO;
import com.sc.nft.entity.dto.TaskStarRewardListDTO;
import com.sc.nft.entity.vo.*;
import com.sc.nft.service.SaasUserTaskService;
import com.sc.nft.sup.PageResult;
import com.sc.nft.sup.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * 用户任务命中(SaasUserTask)表控制层
 *
 * @author 王伟成
 * @since 2024-01-03 18:06:16
 */

@Slf4j
@RequiredArgsConstructor
@RestController
@RequestMapping("/admin/saasUserTask")
@Api(tags = "用户任务命中")
public class SaasUserTaskController {
    /**
     * 服务对象
     */
    private final SaasUserTaskService saasUserTaskService;


    @PostMapping(value = "taskRewardList", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "任务奖励列表(这个是哪些用户完成任务的)", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<TaskRewardListVO> taskRewardList(@RequestBody TaskRewardListDTO taskRewardListDTO) {
        return PageResult.success(saasUserTaskService.taskRewardList(taskRewardListDTO));
    }

    @ApiOperation(value = "根据用户任务完成获取奖励", notes = "根据用户任务完成获取奖励", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @PostMapping(value = "/getByUserTaskIdGainAward", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<List<SaasUserTaskIdGainAwardVO>> getByUserTaskIdGainAward(@Valid @RequestBody IdRequest idRequest) {
        return Result.success(saasUserTaskService.getByUserTaskIdGainAward(idRequest.getId()));
    }

    @PostMapping(value = "taskParticipationRecord", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "任务参与记录", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<TaskParticipationRecordVO> taskParticipationRecord(@RequestBody TaskParticipationRecordDTO taskParticipationRecordDTO) {
        return PageResult.success(saasUserTaskService.taskParticipationRecord(taskParticipationRecordDTO));
    }

    @PostMapping(value = "checkTheProgress", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "查询进度", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public Result<SaasTaskCheckTheProgressVO> checkTheProgress(@RequestBody IdRequest idRequest) {
        return Result.success(saasUserTaskService.checkTheProgress(idRequest.getId()));
    }



    @PostMapping(value = "taskStarRewardList", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "星球任务奖励记录列表", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<TaskStarRewardListVO> taskStarRewardList(@RequestBody TaskStarRewardListDTO taskStarRewardListDTO) {
        return PageResult.success(saasUserTaskService.taskStarRewardList(taskStarRewardListDTO));
    }

    @PostMapping(value = "taskStarParticipationRecord", produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiOperation(value = "星球任务参与记录", httpMethod = "POST", produces = MediaType.APPLICATION_JSON_VALUE)
    @SysMemberLogin
    public PageResult<TaskParticipationRecordVO> taskStarParticipationRecord(@RequestBody TaskParticipationRecordDTO taskParticipationRecordDTO) {
        return PageResult.success(saasUserTaskService.taskStarParticipationRecord(taskParticipationRecordDTO));
    }
}
